package com.rk.pethome.org.service.impl;

import com.rk.pethome.basic.service.impl.BaseServiceImpl;
import com.rk.pethome.org.domain.Employee;
import com.rk.pethome.org.mapper.EmployeeMapper;
import com.rk.pethome.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class IEmployeeServiceImpl extends BaseServiceImpl<Employee> implements IEmployeeService {

    @Autowired
    private EmployeeMapper employeeMapper;
    /**
     * 查询所有的员工列表
     *
     * @return
     */
    @Override
    public List<Employee> loadAll() {
        return employeeMapper.loadAll();
    }

    /**
     * 新增/修改员工
     *
     * @param employee
     */
    @Override
    public void addOrUpdate(Employee employee) {
        if(employee.getId()==null)
        {
            super.add(employee);
        }else {
            super.update(employee);
        }
    }
}
